package com.qidianit.mes.device.service.impl;

import com.qidianit.common.pojo.MESResult;
import com.qidianit.common.util.Constant;
import com.qidianit.mes.device.mapper.ToolsLedgerMapper;
import com.qidianit.mes.device.service.ToolsLedgerService;
import com.qidianit.mes.pojo.MesToolsLedger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class ToolsLedgerServiceImpl implements ToolsLedgerService {
    @Autowired
    ToolsLedgerMapper toolsLedgerMapper;
    @Override
    public MESResult list(String toolCode, String toolName, String toolTypeId, String brand, String model,String status, int page, int limit) {
        List<MesToolsLedger> mesToolsLedgerList = toolsLedgerMapper.list(toolCode,toolName,toolTypeId,brand,model,status);
        return MESResult.success(mesToolsLedgerList);
    }

    @Override
    public MESResult add(MesToolsLedger mesToolsLedger) {
        mesToolsLedger.setIsDeleted(1);
        toolsLedgerMapper.add(mesToolsLedger);
        return MESResult.success(Constant.RESPONSE_STATUS_OK);
    }

    @Override
    public MESResult edit(MesToolsLedger mesToolsLedger) {

        toolsLedgerMapper.edit(mesToolsLedger);
        return MESResult.success(Constant.RESPONSE_STATUS_OK);
    }

    @Override
    public MESResult delete(String toolCode) {
        toolsLedgerMapper.delete(toolCode);
        return MESResult.success(Constant.RESPONSE_STATUS_OK);
    }
}
